package io.renren.modules.area_region.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.area_region.entity.V9AreaRegionEntity;
import io.renren.modules.area_region.service.V9AreaRegionService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-09-24 13:13:13
 */
@RestController
@RequestMapping("area_region/v9arearegion")
public class V9AreaRegionController {
    @Autowired
    private V9AreaRegionService v9AreaRegionService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("area_region:v9arearegion:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = v9AreaRegionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{shippingAreaId}")
    @RequiresPermissions("area_region:v9arearegion:info")
    public R info(@PathVariable("shippingAreaId") Integer shippingAreaId){
		V9AreaRegionEntity v9AreaRegion = v9AreaRegionService.getById(shippingAreaId);

        return R.ok().put("v9AreaRegion", v9AreaRegion);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("area_region:v9arearegion:save")
    public R save(@RequestBody V9AreaRegionEntity v9AreaRegion){
		v9AreaRegionService.save(v9AreaRegion);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("area_region:v9arearegion:update")
    public R update(@RequestBody V9AreaRegionEntity v9AreaRegion){
		v9AreaRegionService.updateById(v9AreaRegion);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("area_region:v9arearegion:delete")
    public R delete(@RequestBody Integer[] shippingAreaIds){
		v9AreaRegionService.removeByIds(Arrays.asList(shippingAreaIds));

        return R.ok();
    }

}